﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BLL;
using IFactory;

public partial class Week_WeekHandShake : System.Web.UI.Page
{
    Authentication dllAuthentication = new Authentication();
    WeekHandShakeManager dllWeekHandShakeManager = new WeekHandShakeManager();
    UserInfoManager dllUserInfo = new UserInfoManager();
    QuarterDateManager dllQuarterDateManager = new QuarterDateManager();
    MonthDateManager dllMonthDateManager = new MonthDateManager();
    WeekDateManager dllWeekDateManager = new WeekDateManager();
    DataTable _userInfo = new DataTable();
    Model.UserInfo objUserInfo = new Model.UserInfo();
    public string _realName = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.RegisterStartupScript("getheighandwidth", "<script>document.getElementById('h1h').value=window.screen.availHeight;document.getElementById('h2w').value= window.screen.width ;</script>");
        this.gdvHandShake.Attributes.Add("style", "word-break:break-all;word-wrap:break-word");
        if (!IsPostBack)
        {
            bindDropDownList(this.drpYear);
            bindDropDownList(this.drpQuarterDate);
            bindDropDownList(this.drpMonthDate);
            bindDropDownList(this.drpWeekDate);
            ListItem _li = this.drpWeekDate.SelectedItem;
            if (_li != null)
            {
                if (_li.Text != "无周周期")
                {
                    bindGridView(_li);
                }
                else
                {
                    this.gdvHandShake.DataSource = createTable();
                    this.gdvHandShake.DataBind();
                }
            }
        }
        this.btnAdd.Enabled = false;
        this.btnDel.Enabled = false;
        this.btnModify.Enabled = false;
        this.btnDisplay.Enabled = false;
        //判断权限，计划管理员拥有修改权
        if (objUserInfo.UserName == "admin")
        {
            this.btnAdd.Enabled = true;
            this.btnDel.Enabled = true;
            this.btnModify.Enabled = true;
            this.btnDisplay.Enabled = true;
        }
        //判断是否为经理，非经理锁定部门选择框        
        int _isManager = dllAuthentication.IsManager(objUserInfo.UserName);
        if (_isManager > 0)
        {
            this.btnAdd.Enabled = true;
        }
    }

    /// <summary>
    /// 生成空白行
    /// </summary>
    /// <returns></returns>
    DataTable createTable()
    {
        DataTable _dt = new DataTable();
        DataColumn dc = new DataColumn("HandShakeId");
        _dt.Columns.Add(dc);
        dc = new DataColumn("CreateDate");
        _dt.Columns.Add(dc);
        dc = new DataColumn("WeekDate");
        _dt.Columns.Add(dc);
        dc = new DataColumn("Sponsor");
        _dt.Columns.Add(dc);
        dc = new DataColumn("Participant");
        _dt.Columns.Add(dc);
        dc = new DataColumn("CompleteTime");
        _dt.Columns.Add(dc);
        dc = new DataColumn("HandShakeContents");
        _dt.Columns.Add(dc);
        dc = new DataColumn("IsConsensus");
        _dt.Columns.Add(dc);
        dc = new DataColumn("CheckNote");
        _dt.Columns.Add(dc);
        dc = new DataColumn("IsDelete");
        _dt.Columns.Add(dc);
        dc = new DataColumn("HandShakeState");
        _dt.Columns.Add(dc);
        DataRow dr = _dt.NewRow();
        dr["HandShakeId"] = "";
        dr["CreateDate"] = "";
        dr["WeekDate"] = "";
        dr["Sponsor"] = "";
        dr["Participant"] = "";
        dr["CompleteTime"] = "";
        dr["HandShakeContents"] = "";
        dr["IsConsensus"] = "";
        dr["CheckNote"] = "0";
        dr["IsDelete"] = "";
        dr["HandShakeState"] = "";
        _dt.Rows.Add(dr);
        return _dt;
    }

    /// <summary>
    /// 绑定GridView
    /// </summary>
    void bindGridView(ListItem _li)
    {
        object[] _user = new object[1];
        _user[0] = objUserInfo.UserName;
        DataTable _usertable = dllUserInfo.get(UserInfoManager.field.UserName.ToString(), _user);
        if (_usertable.Rows.Count > 0)
        {
            _realName = _usertable.Rows[0]["RealName"].ToString();
        }
        object[] _value = new object[1];
        _value[0] = Convert.ToInt32(_li.Value);
        DataTable _weekHandShake = dllWeekHandShakeManager.get(WeekHandShakeManager.field.WeekDate.ToString(), _value);
        this.gdvHandShake.DataSource = _weekHandShake;
        this.gdvHandShake.DataBind();
        if (this.gdvHandShake.Rows.Count > 0)
        {

            for (int i = 0; i < this.gdvHandShake.Rows.Count; i++)
            {
                Button btn = (Button)this.gdvHandShake.Rows[i].Cells[7].FindControl("btnAddMeetingContent");
                btn.Enabled = true;
                if (_weekHandShake.Rows[i]["MeetingContent"].ToString().Length > 0)
                {                    
                    btn.Text = "查看会议记录";
                }
                else
                { 
                    btn.Text = "添加会议记录";
                }
                //判断是否被评估
                if (Convert.ToInt32(_weekHandShake.Rows[i]["HandShakeState"].ToString()) > 0)
                {
                    DropDownList drp = (DropDownList)this.gdvHandShake.Rows[i].Cells[7].FindControl("drpType");
                    drp.Visible = false;
                    TextBox _txtCheckNote = (TextBox)this.gdvHandShake.Rows[i].Cells[7].FindControl("txtCheckNote");
                    _txtCheckNote.Visible = false;
                    btn = (Button)this.gdvHandShake.Rows[i].Cells[7].FindControl("btnOK");
                    btn.Visible = false;
                    Label lbl = (Label)this.gdvHandShake.Rows[i].Cells[7].FindControl("lblHandShake");
                    lbl.Text = _weekHandShake.Rows[i]["CheckNote"].ToString();
                    lbl.Visible = true;
                }
                else
                {
                }
                if (Convert.ToInt32(_weekHandShake.Rows[i]["IsConsensus"].ToString()) == 1)
                {
                    this.gdvHandShake.Rows[i].Cells[6].Text = "达成共识";
                    DropDownList drp = (DropDownList)this.gdvHandShake.Rows[i].Cells[7].FindControl("drpType");
                    drp.SelectedIndex = drp.Items.IndexOf(drp.Items.FindByValue(_weekHandShake.Rows[i]["HandShakeState"].ToString()));
                }
                else
                {
                    this.gdvHandShake.Rows[i].Cells[6].Text = "未达成共识";
                    DropDownList drp = (DropDownList)this.gdvHandShake.Rows[i].Cells[7].FindControl("drpType");
                    drp.SelectedIndex = drp.Items.IndexOf(drp.Items.FindByValue(_weekHandShake.Rows[i]["HandShakeState"].ToString()));
                }
                if (_weekHandShake.Rows[i]["CheckNote"].ToString().Length > 0)
                {
                    TextBox _txtCheckNote = (TextBox)this.gdvHandShake.Rows[i].Cells[7].FindControl("txtCheckNote");
                    _txtCheckNote.Text = _weekHandShake.Rows[i]["CheckNote"].ToString();
                }

                if (Convert.ToInt32(_weekHandShake.Rows[i]["HandShakeState"].ToString()) == 4)
                {
                    gdvHandShake.Rows[i].BackColor = System.Drawing.Color.FromName("#00C0C0");
                }
                if (Convert.ToInt32(_weekHandShake.Rows[i]["HandShakeState"].ToString()) == 5)
                {
                    gdvHandShake.Rows[i].BackColor = System.Drawing.Color.FromName("#00C000");
                }
                if (Convert.ToInt32(_weekHandShake.Rows[i]["HandShakeState"].ToString()) == 6)
                {
                    gdvHandShake.Rows[i].BackColor = System.Drawing.Color.Yellow;
                }
                if (Convert.ToInt32(_weekHandShake.Rows[i]["HandShakeState"].ToString()) == 7)
                {
                    gdvHandShake.Rows[i].BackColor = System.Drawing.Color.Red;
                }


                //判断处理人权限
                if (_realName == this.gdvHandShake.Rows[i].Cells[2].Text || _realName == "admin")
                {
                    DropDownList drp = (DropDownList)this.gdvHandShake.Rows[i].Cells[7].FindControl("drpType");
                    drp.Enabled = true;
                    TextBox tb = (TextBox)this.gdvHandShake.Rows[i].Cells[7].FindControl("txtCheckNote");
                    tb.Enabled = true;
                    btn = (Button)this.gdvHandShake.Rows[i].Cells[7].FindControl("btnOK");
                    btn.Enabled = true;
                }
                wrapByComma(this.gdvHandShake, i, 3);
            }
        }
        else
        {
            this.gdvHandShake.DataSource = createTable();
            this.gdvHandShake.DataBind();
        }
    }

    /// <summary>
    /// 根据逗号换行事件
    /// </summary>
    void wrapByComma(GridView _gridView, int _rowIndex, int _cells)
    {
        string _content = _gridView.Rows[_rowIndex].Cells[_cells].Text;
        _gridView.Rows[_rowIndex].Cells[_cells].Text = _content.Replace("&lt;br&gt;", "<br>");
        //_gridView.Rows[_rowIndex].Cells[_cells].Text = _content.Replace("&gt;", ">");
        _gridView.Rows[_rowIndex].Cells[_cells].Text = _gridView.Rows[_rowIndex].Cells[_cells].Text.Replace(",", "<br>");


    }

    /// <summary>
    /// 绑定所有的dropdownlist
    /// </summary>
    /// <param name="_drp"></param>
    void bindDropDownList(DropDownList _drp)
    {
        //年份绑定
        if (_drp.Equals(this.drpYear))
        {
            for (int i = 2009; i < 2100; i++)
            {
                ListItem _li = new ListItem(i.ToString(), i.ToString());
                _drp.Items.Add(_li);
            }
            //根据系统日期自动绑定到当前年份
            //string _year = DateTime.Now.Year.ToString();
            //this.drpYear.SelectedIndex = this.drpYear.Items.IndexOf(this.drpYear.Items.FindByText(_year));
            //根据系统当前日期查找到对应的年周期
            if (Request.QueryString["Year"] == null)
            {
                DataTable _year = dllQuarterDateManager.getQuarterDate();
                this.drpYear.SelectedIndex = this.drpYear.Items.IndexOf(this.drpYear.Items.FindByText(_year.Rows[0][2].ToString()));
            }
            else
            {
                this.drpYear.SelectedValue = Utility.HttpHelp.getParamsString("Year");
            }
        }

        //绑定年计划周期
        if (_drp.Equals(this.drpQuarterDate))
        {
            object[] _value = new object[1];
            _value[0] = this.drpYear.SelectedValue;
            DataTable _quarter = dllQuarterDateManager.get(QuarterDateManager.field.QuarterYear.ToString(), _value);
            if (_quarter.Rows.Count != 0)
            {
                this.drpQuarterDate.DataSource = _quarter;
                this.drpQuarterDate.DataTextField = "QuarterName";
                this.drpQuarterDate.DataValueField = "Quarter_Id";
                this.drpQuarterDate.DataBind();
                if (Request.QueryString["QuarterDate"] == null)
                {
                    #region dropdownlist显示系统所对应的当前年周期
                    //根据系统当前日期查找到对应的年周期
                    DataTable _quartertime = dllQuarterDateManager.getQuarterDate();
                    //如果查到结果（结果只有一条）

                    if (_quartertime.Rows.Count == 1)
                    {
                        this.drpQuarterDate.SelectedIndex = this.drpQuarterDate.Items.IndexOf(this.drpQuarterDate.Items.FindByText(_quartertime.Rows[0][1].ToString()));
                        this.drpQuarterDate.DataSource = _quartertime;
                        this.drpQuarterDate.DataTextField = "QuarterName";
                        this.drpQuarterDate.DataValueField = "Quarter_Id";
                    }
                    #endregion
                }
                else
                {
                    this.drpQuarterDate.SelectedValue = Utility.HttpHelp.getParamsString("QuarterDate");
                }
                //bindDropDownList(this.drpMonthDate);
            }
            else
            {
                ListItem _li = new ListItem("无年周期");
                this.drpQuarterDate.Items.Clear();
                this.drpQuarterDate.Items.Add(_li);
                //bindDropDownList(this.drpMonthDate);
            }

        }

        //绑定月计划周期
        if (_drp.Equals(this.drpMonthDate))
        {

            object[] _value = new object[2];
            _value[0] = this.drpYear.SelectedValue;
            _value[1] = this.drpQuarterDate.SelectedItem.Text;
            DataTable _month = dllMonthDateManager.get(MonthDateManager.field.QuarterName.ToString(), _value);
            if (_month.Rows.Count != 0)
            {
                this.drpMonthDate.DataSource = _month;
                this.drpMonthDate.DataTextField = "MonthName";
                this.drpMonthDate.DataValueField = "Month_Id";
                this.drpMonthDate.DataBind();
                if (Request.QueryString["MonthDate"] == null)
                {
                    #region 根据系统当前日期绑定到当前月周期
                    DataTable _monthtime = dllMonthDateManager.getMonthDate();
                    if (_monthtime.Rows.Count > 0)
                    {
                        this.drpMonthDate.SelectedIndex = this.drpMonthDate.Items.IndexOf(this.drpMonthDate.Items.FindByText(_monthtime.Rows[0][3].ToString()));

                    }
                    #endregion
                }
                else
                {
                    this.drpMonthDate.SelectedValue = Utility.HttpHelp.getParamsString("MonthDate");
                }
                 

            }
            else
            {
                ListItem _li = new ListItem("无月周期");
                this.drpMonthDate.Items.Clear();
                this.drpMonthDate.Items.Add(_li);
                this.gdvHandShake.DataSource = createTable();
                this.gdvHandShake.DataBind();
            }
        }
        //绑定周计划周期
        if (_drp.Equals(this.drpWeekDate))
        {
            object[] _value = new object[3];
            _value[0] = this.drpYear.SelectedValue;
            _value[1] = this.drpQuarterDate.SelectedItem.Text;
            _value[2] = this.drpMonthDate.SelectedItem.Text;
            DataTable _week = dllWeekDateManager.get(WeekDateManager.field.MonthName.ToString(), _value);
            if (_week.Rows.Count != 0)
            {
                this.drpWeekDate.DataSource = _week;
                this.drpWeekDate.DataTextField = "WeekName";
                this.drpWeekDate.DataValueField = "Week_Id";
                this.drpWeekDate.DataBind();

                if (Request.QueryString["WeekDate"] != null)
                {
                    this.drpWeekDate.SelectedValue = Utility.HttpHelp.getParamsString("WeekDate");
                }
                else
                {
                    DataTable _weektime = dllWeekDateManager.getWeekDate();
                    if (_weektime.Rows.Count > 0)
                    {
                        this.drpWeekDate.SelectedIndex = this.drpWeekDate.Items.IndexOf(this.drpWeekDate.Items.FindByText(_weektime.Rows[0][4].ToString()));
                    }
                }
            }
            else
            {
                ListItem _li = new ListItem("无周周期");
                this.drpWeekDate.Items.Clear();
                this.drpWeekDate.Items.Add(_li);
                this.gdvHandShake.DataSource = createTable();
                this.gdvHandShake.DataBind();
            }
        }
    }

    /// <summary>
    /// 添加周握手关系
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (this.drpWeekDate.SelectedItem != null)
        {
            object[] _value = new object[7];
            _value[0] = this.txtSponsor.Value.Trim();
            _value[1] = this.txtParticipant.Value.Trim();
            _value[2] = this.txtHandShakeContents.Text.Trim();
            _value[3] = Convert.ToDateTime(this.txtCompleteTime.Text.Trim());
            _value[4] = Convert.ToInt32(this.drpWeekDate.SelectedItem.Value);
            _value[5] = Convert.ToInt32(this.drpIsConsensus.SelectedValue);
            _value[6] = this.txtMeetingContent.Text;
            int result = dllWeekHandShakeManager.add(_value);
            if (result == 0)
            {
                Utility.Error.RedirectErrorPage("添加握手关系未成功，请重试！");
            }
            else
            {
                Utility.HttpHelp.redirectPage("WeekHandShake.aspx");
            }
        }
        else
        {
            Utility.HttpHelp.alert("请选择月周期", Page);
        }
    }


    /// <summary>
    /// 处理事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void drpIsConsensus_SelectedIndexChanged(object sender, EventArgs e)
    {
        int i = 0;
        DropDownList drp = (DropDownList)sender;//获得当前控件
        TableCell cell = (TableCell)drp.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        i = iRow.RowIndex;//得到该行的索引
        TextBox tb = (TextBox)this.gdvHandShake.Rows[i].Cells[6].FindControl("txtCheckNote");
        object[] _value = new object[3];
        _value[0] = Convert.ToInt32(this.gdvHandShake.Rows[i].Cells[0].Text);
        _value[1] = Convert.ToInt32(drp.SelectedValue);
        _value[2] = tb.Text;
        int result = dllWeekHandShakeManager.edit(MonthHandShakeManager.field.HandShakeId.ToString(), _value);
        if (result == 0)
        {
            Utility.Error.RedirectErrorPage("审批员工计划未成功，请重试！");
        }
        else
        {
            ListItem _li = this.drpWeekDate.SelectedItem;
            if (_li != null)
            {
                if (_li.Text != "无周周期")
                {
                    bindGridView(_li);
                }
                else
                {
                    this.gdvHandShake.DataSource = createTable();
                    this.gdvHandShake.DataBind();
                }
            }
        }
    }

    /// <summary>
    /// 年改变事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void drpYear_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindDropDownList(this.drpQuarterDate);
        bindDropDownList(this.drpMonthDate);
        bindDropDownList(this.drpWeekDate);
    }


    /// <summary>
    /// 年周期改变事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void drpQuarterDate_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindDropDownList(this.drpMonthDate);
        bindDropDownList(this.drpWeekDate);
    }

    /// <summary>
    /// 月周期改变事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void drpMonthDate_SelectedIndexChanged(object sender, EventArgs e)
    {
        bindDropDownList(this.drpWeekDate);
    }


    /// <summary>
    /// 周周期改变
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void drpWeekDate_SelectedIndexChanged(object sender, EventArgs e)
    {
        ListItem _li = this.drpWeekDate.SelectedItem;
        if (_li != null)
        {
            if (_li.Text != "无周周期")
            {
                bindGridView(_li);
            }
            else
            {
                this.gdvHandShake.DataSource = createTable();
                this.gdvHandShake.DataBind();
            }
        }
    }


    /// <summary>
    /// 提交按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        int i = 0;
        Button bt = (Button)sender;//获得当前控件
        TableCell cell = (TableCell)bt.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        i = iRow.RowIndex;//得到该行的索引
        object[] _value = new object[3];
        _value[0] = Convert.ToInt32(this.gdvHandShake.DataKeys[i]["HandShakeId"].ToString());
        _value[1] = Convert.ToInt32(((DropDownList)this.gdvHandShake.Rows[i].Cells[7].FindControl("drpType")).SelectedValue);
        _value[2] = ((TextBox)this.gdvHandShake.Rows[i].Cells[7].FindControl("txtCheckNote")).Text;
        int result = dllWeekHandShakeManager.edit(WeekHandShakeManager.field.HandShakeId.ToString(), _value);
        if (result == 0)
        {
            Utility.Error.RedirectErrorPage("评估周握手关系未成功，请重试");
        }
        else
        {
            ListItem _li = this.drpWeekDate.SelectedItem;
            if (_li != null)
            {
                if (_li.Text != "无周周期")
                {
                    bindGridView(_li);
                }
            }
        }
    }


    /// <summary>
    /// 自动编号
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void gdvHandShake_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex != -1)
        {
            int id = e.Row.RowIndex + 1;
            e.Row.Cells[1].Text = id.ToString();
        }
    }

    /// <summary>
    /// 删除周握手关系按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        int _count = 0;
        List<object[]> _valueList = new List<object[]>();
        for (int i = 0; i < this.gdvHandShake.Rows.Count; i++)
        {
            CheckBox ckb = (CheckBox)this.gdvHandShake.Rows[i].Cells[0].FindControl("ckbSelect");
            if (ckb.Checked)
            {
                if (Convert.ToInt32(this.gdvHandShake.DataKeys[i]["HandShakeState"].ToString()) > 3 && objUserInfo.UserName != "admin")
                {
                    Utility.HttpHelp.alert("已评估的握手关系不可以删除", Page);
                    ListItem li = this.drpWeekDate.SelectedItem;
                    if (li != null)
                    {
                        if (li.Text != "无周周期")
                        {
                            bindGridView(li);
                        }
                    }
                    return;
                }
                if (this.gdvHandShake.DataKeys[i]["HandShakeId"] != null && this.gdvHandShake.DataKeys[i]["HandShakeId"].ToString().Length > 0 || objUserInfo.UserName == "admin")
                {
                    object[] _value = new object[1];
                    _value[0] = Convert.ToInt32(this.gdvHandShake.DataKeys[i]["HandShakeId"].ToString());
                    _valueList.Add(_value);
                }
            }
        }
        if (_valueList.Count > 0)
        {
            int result = dllWeekHandShakeManager.delWithTransaction(_valueList);
            if (result == 0)
            {
                Utility.Error.RedirectErrorPage("删除周握手关系未成功");
            }

        }

        ListItem _li = this.drpWeekDate.SelectedItem;
        if (_li != null)
        {
            if (_li.Text != "无周周期")
            {
                bindGridView(_li);
            }
        }

    }

    /// <summary>
    /// 修改周握手关系
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnModify_Click(object sender, EventArgs e)
    {
        int _count = 0;
        int _weekHandShake = 0;
        string _weekHandShakeState = "";
        for (int i = 0; i < this.gdvHandShake.Rows.Count; i++)
        {
            CheckBox ckb = (CheckBox)this.gdvHandShake.Rows[i].Cells[0].FindControl("ckbSelect");
            if (ckb.Checked)
            {
                _count++;
                _weekHandShake = Convert.ToInt32(this.gdvHandShake.DataKeys[i]["HandShakeId"].ToString());
                DropDownList drp = (DropDownList)this.gdvHandShake.Rows[i].Cells[7].FindControl("drpType");
                _weekHandShakeState = drp.SelectedItem.Text;
            }
        }

        if (_count > 1)
        {
            Utility.HttpHelp.alert("只能选择一个握手关系", Page);
            return;
        }
        if (_count == 0)
        {
            Utility.HttpHelp.alert("请选择一个握手关系", Page);
            return;
        }
        if (_count == 1)
        {
            if (_weekHandShake == 0)
            {
                Utility.HttpHelp.alert("请选择要修改的握手关系", Page);

            }
            int _isManager = dllAuthentication.IsManager(objUserInfo.UserName);

            if (_weekHandShakeState.Equals("请选择"))
            {
                if (objUserInfo.UserName == "admin")
                {
                    string _url = "ModifyWeekHandShake.aspx?HandShakeId=" + _weekHandShake + "&Year=" + this.drpYear.SelectedValue + "&QuarterDate=" + this.drpQuarterDate.SelectedValue + "&MonthDate=" + this.drpMonthDate.SelectedValue + "&WeekDate=" + this.drpWeekDate.SelectedValue;
                    Page.RegisterStartupScript("windowopen", "<script>window.open('" + _url + "','','height=160,width=900,top=300,left=100,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');</script>");
                }
                if (_weekHandShakeState.Equals("请选择") && _isManager == 0)
                {
                    string _url = "ModifyWeekHandShake.aspx?HandShakeId=" + _weekHandShake + "&Year=" + this.drpYear.SelectedValue + "&QuarterDate=" + this.drpQuarterDate.SelectedValue + "&MonthDate=" + this.drpMonthDate.SelectedValue + "&WeekDate=" + this.drpWeekDate.SelectedValue;
                    Page.RegisterStartupScript("windowopen", "<script>window.open('" + _url + "','','height=160,width=900,top=300,left=100,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');</script>");
                }
            }
            else
            {
                if (objUserInfo.UserName != "admin")
                    Utility.HttpHelp.alert("该握手关系已被评估，不可以修改", Page);
                else
                {
                    string _url = "ModifyWeekHandShake.aspx?HandShakeId=" + _weekHandShake + "&Year=" + this.drpYear.SelectedValue + "&QuarterDate=" + this.drpQuarterDate.SelectedValue + "&MonthDate=" + this.drpMonthDate.SelectedValue + "&WeekDate=" + this.drpWeekDate.SelectedValue;
                    Page.RegisterStartupScript("windowopen", "<script>window.open('" + _url + "','','height=160,width=900,top=300,left=100,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');</script>");
                }

            }
        }
        ListItem _li = this.drpWeekDate.SelectedItem;
        if (_li != null)
        {
            if (_li.Text != "无周周期")
            {
                bindGridView(_li);
            }
        }


    }

    /// <summary>
    /// 周握手关系投影事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDisplay_Click(object sender, EventArgs e)
    {
        string _url = "WeekHandShakeDisplay.aspx";
        string _height = this.h1h.Value;
        string _width = this.h2w.Value;
        Page.RegisterStartupScript("windowsopen", "<script language=javascript>window.open('" + _url + "','newwindow','height= " + _height + ",width=" + _width + ",top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');</script>");
        ListItem _li = this.drpWeekDate.SelectedItem;
        if (_li != null)
        {
            if (_li.Text != "无周周期")
            {
                bindGridView(_li);
            }
            else
            {
                this.gdvHandShake.DataSource = createTable();
                this.gdvHandShake.DataBind();
            }
        }
    }

    /// <summary>
    /// 会议记录按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAddMeetingContent_Click(object sender, EventArgs e)
    {
        int i = 0;
        Button bt = (Button)sender;//获得当前控件
        TableCell cell = (TableCell)bt.Parent;//得到所处的父单元格
        GridViewRow iRow = (GridViewRow)cell.Parent;//得到所处父单元行
        i = iRow.RowIndex;//得到该行的索引

        int HandShakeId = Convert.ToInt32(this.gdvHandShake.DataKeys[i]["HandShakeId"].ToString());
        string _url = "ModifyWeekHandShakeMeeting.aspx?HandShakeId=" + HandShakeId + "&Year=" + this.drpYear.SelectedValue + "&QuarterDate=" + this.drpQuarterDate.SelectedValue + "&MonthDate=" + this.drpMonthDate.SelectedValue + "&WeekDate=" + this.drpWeekDate.SelectedValue;
        Page.RegisterStartupScript("windowopen", "<script>window.open('" + _url + "','','height=420,width=930,top=300,left=100,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');</script>");
        ListItem _li = this.drpWeekDate.SelectedItem;
        if (_li != null)
        {
            bindGridView(_li);
        }
    }
}
